const Gpio = require('onoff').Gpio; // Gpio class
const led = new Gpio(12, 'out');       // Export GPIO17 as an output
let stopBlinking = false;

const blinkLed = _ => {
    if (stopBlinking) {
            return led.unexport();
          
    }

      led.read((err, value) => { // Asynchronous read
          console.log('read value ' + value);
          if (err) {
                    throw err;
                  
          }
      
          led.write(value ^ 1, err => { // Asynchronous write
              if (err) {
                          throw err;
                        
              }
              });
        });

      setTimeout(blinkLed, 200);
    
};

blinkLed();
